#include<math.h>
#include<stdio.h>
#include<ctype.h>
double atof(char []);
int main()
{
  char s[100];
  printf("enter a floating point number");
  fgets(s,100,stdin);
  printf("the number is %f",atof(s));
  return 0;
}

double atof(char s[])
{
 double val,val1,power;
 int i,sign1,sign2;

 for(i=0;isspace(s[i]);i++);//skiping white space characters
 sign1=(s[i]=='-')?-1:1;
 
 if(s[i]=='-' || s[i]=='+')
   i++;
   
 for(val=0.0;isdigit(s[i]);i++)
   val=val*10.0 + (s[i]-'0');
   
 if(s[i]=='.')
   i++;
   
 for(power=1.0;isdigit(s[i]);i++)
  {
   val=val*10.0 + (s[i]-'0');
   power=power*10.0;
  }
  
  if(s[i]=='e' || s[i]=='E')
    i++;
  
  sign2=(s[i]=='-')?-1:1;
  
  if(s[i]=='+' ||s[i]=='-')
    i++;
  
 for(val1=0;isdigit(s[i]);i++)
  {
    val1=val1*10 + (s[i]-'0');
  }
  
  if(sign2==-1)
     power=power*pow(10,val1);
  else 
     power=power/pow(10,val1);
 
  return (val*sign1)/power;
}
   
   

    
    
    
  
